package metalink.admin;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
import java.sql.*;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import vo.*;
import vo.mixed.*;
import model.admin.*;
import myutil.*;


public class InsertStaffListIntoDatabase extends ActionSupport {
public String execute(){
	try {
		int count=0;
		Connect c=new Connect();
		HttpSession session = ServletActionContext.getRequest().getSession();
		ArrayList<CollegeStaffVo> staff_list=(ArrayList<CollegeStaffVo>)session.getAttribute("uploaded_staff_list");
		if(staff_list!=null){
		for(CollegeStaffVo single_object:staff_list){
			c.dml("insert into college_staff(staff_name,designation,joining_date,phone_number,address_line,city,state,country,email_id,staff_type,role,roll_number,acc_no) values('"+single_object.getStaff_name()+"','"+single_object.getDesignation()+"','"+single_object.getJoining_date()+"','"+single_object.getPhone_number()+"','"+single_object.getAddress_line()+"','"+single_object.getCity()+"','"+single_object.getState()+"','"+single_object.getCountry()+"','"+single_object.getEmail_id()+"','"+single_object.getStaff_type()+"','"+single_object.getRole()+"','"+single_object.getRoll_number()+"','"+single_object.getAcc_no()+"')");
		++count;
		
		}
		addActionError(count+" records are inserted successfully");
		return SUCCESS;
		}
		
		return ERROR;
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return ERROR;
	}
}
}
